package cn.bytecollege.admin.controller;

import cn.bytecollege.admin.service.CategoryService;
import cn.bytecollege.common.constant.Resource;
import cn.bytecollege.common.entity.Category;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "CategoryListController", value = "/admin/categoryList")
public class CategoryListController extends HttpServlet {
    private CategoryService categoryService=null;
    public CategoryListController(){
        categoryService=new CategoryService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.接受请求参数
        List<Category>list=categoryService.find();
        //2.封装数据
        request.setAttribute("list",list);
        request.getRequestDispatcher(Resource.PAGE_LOCATION+"/admin/categoryList.jsp").forward(request,response);
    }
}

